package weaver.interfaces.cetc.action;

import com.weaver.general.BaseBean;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.cetc.action.util.WebServiceUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2021-10-28
 * @Description: 生产商年度评价记录表
 * @ModifyLog:
 **/
/*
 *@Description: 流程提交后调用调用浪潮--更新生产商信息接口
 *@Param:
 *@return:
 *@Author: Dusongsong
 *@Date: 2020/12/10
 */
public class WeaScsndpjjlbAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        BaseBean baseBean = new BaseBean();
        baseBean.writeLog( "-----WeaScsndpjjlbAction-----" );
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        try {
            String sql = "select gysbh,sqr,sqrq,pjjl,gfdj,df11 from " + tablename + " where requestid=?";
            rs.executeQuery( sql, requestid );
            rs.next();
            String vendorCode = Util.null2String( rs.getString( "gysbh" ) );//供应商编号
            if (!"".equals( vendorCode )) {
                String jl = Util.null2String( rs.getString( "pjjl" ) );//结论
                String score = Util.null2String( rs.getString( "df11" ) );//分数
                String modifier = Util.null2String( rs.getString( "sqr" ) );//修改人
                String mofifyTime = Util.null2String( rs.getString( "sqrq" ) ).replace( "-","." );//修改时间
                String vendorIdentify = "";//供应商标识
                if("0".equals( jl)||"1".equals( jl)){
                    vendorIdentify = "2";
                }
                if("2".equals( jl)){
                    vendorIdentify = "3";
                }
                String level = Util.null2String( rs.getString( "gfdj" ) );//评价等级
                String result = WebServiceUtil.updateScsInfo( vendorCode, jl, score, modifier, mofifyTime, vendorIdentify, level );
                baseBean.writeLog( "result=" + result.toString() );
            }
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            writeLog( "异常参考:" + e );
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "Action接口异常！" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
